package trial;

import java.io.FileNotFoundException;
import java.io.OutputStream;

import org.docx4j.Docx4J;
import org.docx4j.Docx4jProperties;
import org.docx4j.convert.out.HTMLSettings;
import org.docx4j.openpackaging.exceptions.Docx4JException;
import org.docx4j.openpackaging.packages.WordprocessingMLPackage;
import org.docx4j.samples.AbstractSample;

public class doc2XHTML extends AbstractSample{

	
	static String dir;
	static {
		dir = "/home/noel/swp/xaoc/src/trial/samle-docs/docx/"; //System.getProperty("user.dir") + 
		inputfilepath = "EBNF-Uebung11-12.docx";
		
	}

	
	
	public static void main(String[] args) throws FileNotFoundException, Docx4JException {
		System.out.println(dir);
		
		Docx4jProperties.setProperty("docx4j.Convert.Out.HTML.OutputMethodXML", true);
		
		try {
			getInputFilePath(args);
		} catch (IllegalArgumentException e) {
		}

		System.out.println(inputfilepath);
		
		WordprocessingMLPackage wordMLPackage = WordprocessingMLPackage.load(new java.io.File(dir+inputfilepath));
		
		// XHTML export
		HTMLSettings htmlSettings = new HTMLSettings();
		htmlSettings.setWmlPackage(wordMLPackage);
		htmlSettings.setImageDirPath(dir + inputfilepath + "_files");
		htmlSettings.setImageTargetUri(dir + inputfilepath + "_files");
		
		String htmlFilePath = dir + "/DocxToXhtml.html";
		//String htmlFilePath = dir + "/DocxToXhtml.pdf";
		OutputStream os = new java.io.FileOutputStream(htmlFilePath);
		
		Docx4J.toHTML(htmlSettings, os, Docx4J.FLAG_NONE);
		
	

	}

}
